#pragma once

#include <iostream>
#include <functional>
#include <vector>
#include <ctime>

// typedef std::function<void()> task_t;
using task_t = std::function<void()>;

void download()
{
    std::cout << "download..." << std::endl;
}

void printLog()
{
    std::cout << "printLog..." << std::endl;
}

void pushVideoStream()
{
    std::cout << "pushVideoStream..." << std::endl;
}


class Tasks
{
public:
    Tasks()
    {
        taskList.push_back(download);
        taskList.push_back(printLog);
        taskList.push_back(pushVideoStream);
        srand(time(nullptr));
    }

    bool checkSafe(int code)
    {
        if(code >= 0 && code < taskList.size()) return true;
        else return false;
    }

    void runTask(int code)
    {
        taskList[code]();
    }

    int selectTask()
    {
        return rand() % taskList.size();
    }
public:
    //任务码
    const static int g_download_code = 0;
    const static int g_print_log_code = 1;
    const static int g_push_video_stream_code = 2;
    //任务
    std::vector<task_t> taskList;
};

Tasks tasks;